/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package dtomapper;

import java.awt.HeadlessException;
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JFileChooser;
import javax.swing.JTextField;

/**
 *
 * @author f4733401, Mlungisi Sincuba<mlungisi.sincuba@fnb.co.za>
 */
public class MapperFrame extends javax.swing.JFrame {

    /**
     * Creates new form FileCreaterFrame
     */
    public MapperFrame() {
        initComponents();
        setResizable(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jtfModelSource = new javax.swing.JTextField();
        jbtBrowseModelSource = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jtfDTOSource = new javax.swing.JTextField();
        jbtBrowseDTOSource1 = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jbtGenerate = new javax.swing.JButton();
        jbtCancel = new javax.swing.JButton();
        jtfDaoIntefaces = new javax.swing.JTextField();
        jtfDaoClasses = new javax.swing.JTextField();
        jtfEjbInterfaces = new javax.swing.JTextField();
        jtfEjbClasses = new javax.swing.JTextField();
        jbtEjbClasses = new javax.swing.JButton();
        jbtEjbInterfaces = new javax.swing.JButton();
        jbtDaoInterfaces = new javax.swing.JButton();
        jbtDaoClases = new javax.swing.JButton();
        jtfMapperFile = new javax.swing.JTextField();
        jbtMapperFile = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jtfMenubarFiles = new javax.swing.JTextField();
        jbtMenubarBrowse = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jtfXmlProperties = new javax.swing.JTextField();
        jbtXmlProperties = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Mapper");

        jLabel1.setText("Model Source Files");

        jbtBrowseModelSource.setText("...");
        jbtBrowseModelSource.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtBrowseModelSourceActionPerformed(evt);
            }
        });

        jLabel2.setText("DTO Source Files");

        jbtBrowseDTOSource1.setText("...");
        jbtBrowseDTOSource1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtBrowseDTOSource1ActionPerformed(evt);
            }
        });

        jLabel4.setText("DAO Interfaces Files");

        jLabel5.setText("DAO Classes File");

        jLabel6.setText("EBJ Interfaces Files");

        jLabel7.setText("EJB Classes Files");

        jbtGenerate.setText("Generate");
        jbtGenerate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtGenerateActionPerformed(evt);
            }
        });

        jbtCancel.setText("Cancel");
        jbtCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtCancelActionPerformed(evt);
            }
        });

        jtfEjbInterfaces.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfEjbInterfacesActionPerformed(evt);
            }
        });

        jbtEjbClasses.setText("...");
        jbtEjbClasses.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtEjbClassesActionPerformed(evt);
            }
        });

        jbtEjbInterfaces.setText("...");
        jbtEjbInterfaces.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtEjbInterfacesActionPerformed(evt);
            }
        });

        jbtDaoInterfaces.setText("...");
        jbtDaoInterfaces.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtDaoInterfacesActionPerformed(evt);
            }
        });

        jbtDaoClases.setText("...");
        jbtDaoClases.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtDaoClasesActionPerformed(evt);
            }
        });

        jbtMapperFile.setText("...");
        jbtMapperFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtMapperFileActionPerformed(evt);
            }
        });

        jLabel3.setText("Mapper Class File");

        jLabel8.setText("Menubar Files");

        jbtMenubarBrowse.setText("...");
        jbtMenubarBrowse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtMenubarBrowseActionPerformed(evt);
            }
        });

        jLabel9.setText("XML Properties Files");

        jbtXmlProperties.setText("...");
        jbtXmlProperties.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtXmlPropertiesActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel3))
                                .addGap(66, 66, 66))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jtfDTOSource, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                                    .addComponent(jtfModelSource))
                                .addGap(10, 10, 10)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jbtBrowseDTOSource1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jbtBrowseModelSource, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jtfDaoIntefaces, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jbtDaoInterfaces, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jtfDaoClasses, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jbtDaoClases, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jtfEjbInterfaces, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jbtEjbInterfaces, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jtfMapperFile, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jbtMapperFile, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel7)
                            .addComponent(jLabel8)
                            .addComponent(jLabel9))
                        .addGap(59, 59, 59)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jtfEjbClasses)
                                    .addComponent(jtfMenubarFiles))
                                .addGap(10, 10, 10)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jbtEjbClasses, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jbtMenubarBrowse, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jtfXmlProperties, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jbtXmlProperties, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jbtGenerate)
                .addGap(18, 18, 18)
                .addComponent(jbtCancel)
                .addGap(91, 91, 91))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtfModelSource, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtBrowseModelSource))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtfDTOSource, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtBrowseDTOSource1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jtfMapperFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtMapperFile))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfDaoIntefaces, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtDaoInterfaces)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfDaoClasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtDaoClases)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfEjbInterfaces, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtEjbInterfaces)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfXmlProperties, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(jbtXmlProperties))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfEjbClasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtEjbClasses)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jtfMenubarFiles, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jbtMenubarBrowse)))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtCancel)
                    .addComponent(jbtGenerate))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void jbtGenerateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtGenerateActionPerformed
        String modelSourcePath = jtfModelSource.getText();
        FileCreater m = new FileCreater();
        if (modelSourcePath != null || !"".equals(modelSourcePath)) {
            File sourceModelPath = new File(modelSourcePath);
            File[] sourceModelFiles = sourceModelPath.listFiles(new FileFilter() {

                @Override
                public boolean accept(File pathname) {
                    String name = pathname.getName();
                    int index = name.lastIndexOf(".");
                    String ext = name.substring(index + 1).toLowerCase();
                    return ext.equals("java");
                }
            });
            List<String> entityclasses = new ArrayList<>();
            String packageName = modelSourcePath != null
                    ? modelSourcePath.substring(modelSourcePath.indexOf("/java/") + 6).replace("/", ".") : "";
            packageName = packageName + ".";
            System.out.println("packageName: " + packageName);
            for (File file : sourceModelFiles) {
                String fileName = file.getName();
                String entity = fileName.substring(0, fileName.indexOf("."));
                entityclasses.add(entity);
                if (jtfDaoIntefaces.getText() != null && !"".equals(jtfDaoIntefaces.getText())) {
                    m.generateDaoInterface(entity, jtfDaoIntefaces.getText());
                }
                if (jtfDaoClasses.getText() != null && !"".equals(jtfDaoClasses.getText())) {
                    m.generateDaoClass(entity, jtfDaoClasses.getText());
                }
                if (jtfEjbInterfaces.getText() != null && !"".equals(jtfEjbInterfaces.getText())) {
                    m.generateEjbInterface(entity, jtfEjbInterfaces.getText());
                }
                if (jtfEjbClasses.getText() != null && !"".equals(jtfEjbClasses.getText())) {
                    m.generateEjbClass(entity, jtfEjbClasses.getText());
                }

            }
            if (jtfMapperFile.getText() != null && !"".equals(jtfMapperFile.getText())) {
//                m.generateMapper(entityclasses, jtfMapperFile.getText());
                m.generateMapper(packageName, entityclasses, jtfMapperFile.getText());
            }
            if (jtfMenubarFiles.getText() != null && !"".equals(jtfMenubarFiles.getText())) {
                for (String entity : entityclasses) {
                    m.generateMenubar(entity, jtfMenubarFiles.getText());
                }
            }
            if (jtfXmlProperties.getText() != null && !"".equals(jtfXmlProperties.getText())) {
                m.generateXmlProperty(packageName, entityclasses, jtfXmlProperties.getText());
            }
        }
    }//GEN-LAST:event_jbtGenerateActionPerformed

    private void jtfEjbInterfacesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfEjbInterfacesActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtfEjbInterfacesActionPerformed

    private void jbtBrowseModelSourceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtBrowseModelSourceActionPerformed
        appendTextValue(jtfModelSource);
    }//GEN-LAST:event_jbtBrowseModelSourceActionPerformed

    private void jbtBrowseDTOSource1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtBrowseDTOSource1ActionPerformed
        appendTextValue(jtfDTOSource);
    }//GEN-LAST:event_jbtBrowseDTOSource1ActionPerformed

    private void jbtMapperFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtMapperFileActionPerformed
        appendTextValue(jtfMapperFile);
    }//GEN-LAST:event_jbtMapperFileActionPerformed

    private void jbtDaoInterfacesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtDaoInterfacesActionPerformed
        appendTextValue(jtfDaoIntefaces);
    }//GEN-LAST:event_jbtDaoInterfacesActionPerformed

    private void jbtDaoClasesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtDaoClasesActionPerformed
        appendTextValue(jtfDaoClasses);
    }//GEN-LAST:event_jbtDaoClasesActionPerformed

    private void jbtEjbInterfacesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtEjbInterfacesActionPerformed
        appendTextValue(jtfEjbInterfaces);
    }//GEN-LAST:event_jbtEjbInterfacesActionPerformed

    private void jbtEjbClassesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtEjbClassesActionPerformed
        appendTextValue(jtfEjbClasses);
    }//GEN-LAST:event_jbtEjbClassesActionPerformed

    private void jbtCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtCancelActionPerformed
        System.exit(0);
    }//GEN-LAST:event_jbtCancelActionPerformed

    private void jbtMenubarBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtMenubarBrowseActionPerformed
        appendTextValue(jtfMenubarFiles);
    }//GEN-LAST:event_jbtMenubarBrowseActionPerformed

    private void jbtXmlPropertiesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtXmlPropertiesActionPerformed
        appendTextValue(jtfXmlProperties);
    }//GEN-LAST:event_jbtXmlPropertiesActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MapperFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new MapperFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JButton jbtBrowseDTOSource1;
    private javax.swing.JButton jbtBrowseModelSource;
    private javax.swing.JButton jbtCancel;
    private javax.swing.JButton jbtDaoClases;
    private javax.swing.JButton jbtDaoInterfaces;
    private javax.swing.JButton jbtEjbClasses;
    private javax.swing.JButton jbtEjbInterfaces;
    private javax.swing.JButton jbtGenerate;
    private javax.swing.JButton jbtMapperFile;
    private javax.swing.JButton jbtMenubarBrowse;
    private javax.swing.JButton jbtXmlProperties;
    private javax.swing.JTextField jtfDTOSource;
    private javax.swing.JTextField jtfDaoClasses;
    private javax.swing.JTextField jtfDaoIntefaces;
    private javax.swing.JTextField jtfEjbClasses;
    private javax.swing.JTextField jtfEjbInterfaces;
    private javax.swing.JTextField jtfMapperFile;
    private javax.swing.JTextField jtfMenubarFiles;
    private javax.swing.JTextField jtfModelSource;
    private javax.swing.JTextField jtfXmlProperties;
    // End of variables declaration//GEN-END:variables

    private void appendTextValue(JTextField textField) throws HeadlessException {
        JFileChooser chooser = new JFileChooser();
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int dialog = chooser.showOpenDialog(this);
        if (dialog == JFileChooser.APPROVE_OPTION) {
            File selectedPath = chooser.getSelectedFile();
            String path = selectedPath.getAbsolutePath().replace("\\", "/");
            System.out.println("path: " + path);
            textField.setText(path);
        }
    }
}
